define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'file/equip/index' + location.search,
                    add_url: 'file/equip/add',
                    edit_url: 'file/equip/edit',
                    del_url: 'file/equip/del',
                    multi_url: 'file/equip/multi',
                    import_url: 'file/equip/import',
                    table: 'equip',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search:false,
                exportTypes:['excel'],
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),operate: false},
                        {field: 'class', title: __('Class'),operate: false,visible:false},
                        {field: 'quality', title: __('Quality'),operate: false,visible:false},
                        {field: 'type', title: __('Type'),operate: false,visible:false},
                        {field: 'index', title: __('Index'),operate: false,visible:false},
                        {field: 'equip_point', title: __('Equip_point'),operate: false,visible:false},
                        {field: 'visual', title: __('Visual'),operate: false,visible:false},
                        {field: 'rule', title: __('Rule'),operate: false,visible:false},
                        {field: 'suit_id', title: __('Suit_id'),operate: false,visible:false},
                        {field: 'suit_value', title: __('Suit_value'),operate: false,visible:false},
                        {field: 'name', title: __('Name'),operate: 'LIKE %...%', placeholder: '模糊搜索'},
                        {field: 'lv', title: __('Lv'),operate: false},
                        {field: 'menpai', title: __('Menpai'),operate: false,visible:false},
                        {field: 'desc', title: __('Desc'),operate: false,visible:false},
                        {field: 'price', title: __('Price'),operate: false,visible:false},
                        {field: 'sale_price', title: __('Sale_price'),operate: false,visible:false},
                        {field: 'max_value', title: __('Max_value'),operate: false,visible:false},
                        {field: 'fix_fail_value', title: __('Fix_fail_value'),operate: false,visible:false},
                        {field: 'max_gem', title: __('Max_gem'),operate: false,visible:false},
                        {field: 'skill_id', title: __('Skill_id'),operate: false,visible:false},
                        {field: 'script_id', title: __('Script_id'),operate: false,visible:false},
                        {field: 'icon', title: __('Icon'),operate: false,visible:false},
                        {field: 'desc_type', title: __('Desc_type'),operate: false,visible:false},
                        {field: 'piao_id', title: __('Piao_id'),operate: false,visible:false},
                        {field: 'is_zz', title: __('Is_zz'),operate: false,visible:false},
                        {field: 'is_pz', title: __('Is_pz'),operate: false,visible:false},
                        {field: 'basic_phy_attack', title: __('Basic_phy_attack'),operate: false,visible:false},
                        {field: 'basic_mag_attack', title: __('Basic_mag_attack'),operate: false,visible:false},
                        {field: 'basic_phy_def', title: __('Basic_phy_def'),operate: false,visible:false},
                        {field: 'basic_mag_def', title: __('Basic_mag_def'),operate: false,visible:false},
                        {field: 'basic_hit', title: __('Basic_hit'),operate: false,visible:false},
                        {field: 'basic_miss', title: __('Basic_miss'),operate: false,visible:false},
                        {field: 'hp_max_value', title: __('Hp_max_value'),operate: false,visible:false},
                        {field: 'hp_max_percent', title: __('Hp_max_percent'),operate: false,visible:false},
                        {field: 'hp_back_value', title: __('Hp_back_value'),operate: false,visible:false},
                        {field: 'mp_max_value', title: __('Mp_max_value'),operate: false,visible:false},
                        {field: 'mp_max_percent', title: __('Mp_max_percent'),operate: false,visible:false},
                        {field: 'mp_back_value', title: __('Mp_back_value'),operate: false,visible:false},
                        {field: 'cold_att', title: __('Cold_att'),operate: false,visible:false},
                        {field: 'cold_def', title: __('Cold_def'),operate: false,visible:false},
                        {field: 'cold_keep_time', title: __('Cold_keep_time'),operate: false,visible:false},
                        {field: 'fire_att', title: __('Fire_att'),operate: false,visible:false},
                        {field: 'fire_def', title: __('Fire_def'),operate: false,visible:false},
                        {field: 'fire_keep_time', title: __('Fire_keep_time'),operate: false,visible:false},
                        {field: 'light_att', title: __('Light_att'),operate: false,visible:false},
                        {field: 'light_def', title: __('Light_def'),operate: false,visible:false},
                        {field: 'light_keep_time', title: __('Light_keep_time'),operate: false,visible:false},
                        {field: 'postion_att', title: __('Postion_att'),operate: false,visible:false},
                        {field: 'postion_def', title: __('Postion_def'),operate: false,visible:false},
                        {field: 'postion_keep_time', title: __('Postion_keep_time'),operate: false,visible:false},
                        {field: 'def_all_percent', title: __('Def_all_percent'),operate: false,visible:false},
                        {field: 'phy_attack', title: __('Phy_attack'),operate: false,visible:false},
                        {field: 'phy_attack_percent', title: __('Phy_attack_percent'),operate: false,visible:false},
                        {field: 'add_phy_attack_percent', title: __('Add_phy_attack_percent'),operate: false,visible:false},
                        {field: 'phy_def', title: __('Phy_def'),operate: false,visible:false},
                        {field: 'phy_def_percent', title: __('Phy_def_percent'),operate: false,visible:false},
                        {field: 'add_phy_def_percent', title: __('Add_phy_def_percent'),operate: false,visible:false},
                        {field: 'miss_phy_def_percent', title: __('Miss_phy_def_percent'),operate: false,visible:false},
                        {field: 'mag_attack', title: __('Mag_attack'),operate: false,visible:false},
                        {field: 'mag_attack_percent', title: __('Mag_attack_percent'),operate: false,visible:false},
                        {field: 'add_mag_attack_percent', title: __('Add_mag_attack_percent'),operate: false,visible:false},
                        {field: 'mag_def', title: __('Mag_def'),operate: false,visible:false},
                        {field: 'mag_def_percent', title: __('Mag_def_percent'),operate: false,visible:false},
                        {field: 'add_mag_def_percent', title: __('Add_mag_def_percent'),operate: false,visible:false},
                        {field: 'miss_mag_def_percent', title: __('Miss_mag_def_percent'),operate: false,visible:false},
                        {field: 'attach_speed', title: __('Attach_speed'),operate: false,visible:false},
                        {field: 'mag_cold_time', title: __('Mag_cold_time'),operate: false,visible:false},
                        {field: 'hit', title: __('Hit'),operate: false,visible:false},
                        {field: 'miss', title: __('Miss'),operate: false,visible:false},
                        {field: 'critical_att', title: __('Critical_att'),operate: false,visible:false},
                        {field: 'ignore_percent', title: __('Ignore_percent'),operate: false,visible:false},
                        {field: 'move_percent', title: __('Move_percent'),operate: false,visible:false},
                        {field: 'attack_back', title: __('Attack_back'),operate: false,visible:false},
                        {field: 'attach_cost', title: __('Attach_cost'),operate: false,visible:false},
                        {field: 'str', title: __('Str'),operate: false,visible:false},
                        {field: 'spr', title: __('Spr'),operate: false,visible:false},
                        {field: 'con', title: __('Con'),operate: false,visible:false},
                        {field: 'com', title: __('Com'),operate: false,visible:false},
                        {field: 'dex', title: __('Dex'),operate: false,visible:false},
                        {field: 'critical_def', title: __('Critical_def'),operate: false,visible:false},
                        {field: 'qian_neng', title: __('Qian_neng'),operate: false,visible:false},
                        {field: 'hp_sto', title: __('Hp_sto'),operate: false,visible:false},
                        {field: 'mp_sto', title: __('Mp_sto'),operate: false,visible:false},
                        {field: 'add_skill_lv', title: __('Add_skill_lv'),operate: false,visible:false},
                        {field: 'add_all_skill_lv', title: __('Add_all_skill_lv'),operate: false,visible:false},
                        {field: 'spe_skill_rate', title: __('Spe_skill_rate'),operate: false,visible:false},
                        {field: 'Resist_cold_def', title: __('Resist_cold_def'),operate: false,visible:false},
                        {field: 'Resist_fire_def', title: __('Resist_fire_def'),operate: false,visible:false},
                        {field: 'Resist_light_def', title: __('Resist_light_def'),operate: false,visible:false},
                        {field: 'Resist_postion_def', title: __('Resist_postion_def'),operate: false,visible:false},
                        {field: 'quality_rule', title: __('Quality_rule'),operate: false,visible:false},
                        {field: 'begin_attr', title: __('Begin_attr'),operate: false,visible:false},
                        {field: 'attr_min', title: __('Attr_min'),operate: false,visible:false},
                        {field: 'attr_max', title: __('Attr_max'),operate: false,visible:false},
                        {field: 'zz_min', title: __('Zz_min'),operate: false,visible:false},
                        {field: 'zz_max', title: __('Zz_max'),operate: false,visible:false},
                        {field: 'level_up_id', title: __('Level_up_id'),operate: false,visible:false},
                        {field: 'bag', title: __('Bag'),operate: false,visible:false},
                        {field: 'box', title: __('Box'),operate: false,visible:false},
                        {field: 'is_boradcast', title: __('Is_boradcast'),operate: false,visible:false},
                        {field: 'float_space', title: __('Float_space'),operate: false,visible:false},
                        {field: 'quality_level', title: __('Quality_level'),operate: false,visible:false},
                        {
                            field: 'buttons',
                            width: "120px",
                            title: '操作',
                            table: table,
                            operate:false,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'detail',
                                    text: '详情',
                                    title:'详情',
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-list',
                                    url: 'file/equip/detail',
                                    callback: function (data) {
                                        Layer.alert("接收到回传数据：" + JSON.stringify(data), {title: "回传数据"});
                                    },
                                    visible: true
                                }
                            ],
                            formatter: Table.api.formatter.buttons
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});